﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Model;
namespace Manager
{
    public class DistrictCache
    {
        public static Dictionary<string, IList<string>> MyDistricts = new Dictionary<string, IList<string>>();
        public static void Clear()
        {
            MyDistricts.Clear();
        }
        public static bool CheckExist(string district,string child)
        {
            if (!MyDistricts.ContainsKey(district))
            {
                HW_DistrictManager manager = new HW_DistrictManager();
                List<string> districts=new List<string> ();
                IList<HW_District> entity=manager.GetSubList(district);
                foreach(HW_District d in entity)
                {
                    districts.Add(d.DistrictCode);
                }
                MyDistricts.Add(district, districts);
            }
            if (MyDistricts[district].Contains(child))
                return true;
            else
                return false;
        }
    }
}